package Thread;

/**
 * @description: ThreadDownload
 * 多线程图片下载
 *
 * @date: 2019/12/19 17:34
 * @author: Vicuna
 */

public class ThreadDownload implements Runnable{
    private String url;
    private String dest;
    public ThreadDownload(String url,String dest)
    {
        this.url=url;
        this.dest=dest;
    }
    @Override
    public void run() {
    WebDownloadUtils web =new WebDownloadUtils();
    web.download(url,dest);
    }

    public static void main(String[] args) {                        //开三个线程
        ThreadDownload t1=new ThreadDownload("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576758881007&di=abc84a0d762da6817abea68de1865013&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3D85041cc6530fd9f9a0175561152cd42b%2Fed7befef76094b36c2532857a1cc7cd98f109d99.jpg",
                "images/t1.jpg");
        ThreadDownload t2=new ThreadDownload("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576758881007&di=803bfe6482e8961fedd5fcc4f6698a3b&imgtype=0&src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20171212%2F2f56e7bb70624c66a3a41066171a4d13.gif",
                "images/t2.jpg");
        ThreadDownload t3=new ThreadDownload("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1576758927119&di=e342a95c9ceb4e6245634879fc0507c2&imgtype=jpg&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3D129cbdb449166d223877159c76220945%2Fd33e3a3e6709c93d37a83488953df8dcd100541b.jpg",
                "images/t3.jpg");
        new Thread(t1).start();
        new Thread(t2).start();
        new Thread(t3).start();
//        t2.start();
//        t3.start();
    }
}
